﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMS.Data.Classes;

namespace CMS.Data.Repositorios
{
    public class RuaRepository
    {
        ImobiliariaDataContext Context = new ImobiliariaDataContext();

        public void Save(Rua imov)
        {
            if (imov.Rua_ID == 0)
                Context.Ruas.InsertOnSubmit(imov);

            Context.SubmitChanges();
        }

        public void Delete(Rua imov)
        {
            Context.Ruas.DeleteOnSubmit(imov);
            Context.SubmitChanges();
        }

        public IEnumerable<Rua> SelectAll()
        {
            return Context.Ruas;
        }

        public Rua SelectById(int Id)
        {
            return Context.Ruas.Where(x => x.Rua_ID == Id).FirstOrDefault();
        }

    }

}
